package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.ScheduleLeftBean;
import com.wenlin.myproduction.util.Checker;
import com.wenlin.myproduction.util.ToastUtils;
import com.wenlin.myproduction.util.UI;

import me.drakeet.multitype.ItemViewBinder;

/**
 * @author 文琳_377979485@qq.com
 * @time 2021/10/13 0013 上午 9:23
 * @desc 排班管理的左侧列表条目——护士名称列表条目
 */
public class ScheduleLeftBinder extends ItemViewBinder<ScheduleLeftBean, ScheduleLeftBinder.ScheduleLeftHolder> {

    @NonNull
    @Override
    protected ScheduleLeftHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new ScheduleLeftHolder(inflater.inflate(R.layout.item_schedule_left, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull ScheduleLeftHolder holder, @NonNull ScheduleLeftBean item) {
        String name = item.getListsDTO().getRealname();
        UI.setText(holder.tv, Checker.hasWord(name) ? name : "");
        UI.setOnClickListener(holder.tv, v -> ToastUtils.getInstance().showToast(name));
    }

    static class ScheduleLeftHolder extends RecyclerView.ViewHolder {
        TextView tv;

        public ScheduleLeftHolder(@NonNull View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv);
        }
    }
}
